<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="3s/booklet/jquery-1.7.2.min.js"></script>
	<script>
	$(function(){
		$("#submit").click(function(){
			$.post("app/sanshishu/selectTable",{table:$("#table").val()},function(dat){
			$("#content").html("");
				for(var i=0;i<dat.length;i++){
					var tr = "<tr>"
					for(var o in dat[i]){
						tr += "<td><textarea class='param_"+dat[i]["id"]+"'>"+dat[i][o]+"</textarea></td>";
					}
					tr += "<td><button onclick=update("+dat[i]["id"]+")>update</button></td></tr>";
					$("#content").append(tr)
				}
			})
		})
	})
	function update(id){
		var params = [];
		$(".param_"+id).each(function(v){
			params.push($(this).val());
		})
		$.post("app/sanshishu/updateRow",{table:$("#table").val(),id:id,params:params},function(dat){
			if(dat == 1){
				alert('更新成功')
			}else{
				alert('更新失败')
			}
		})
	}
	</script>
	<style>
	textarea{
		width: 100%;
		height: 200;
	}
	</style>
  </head>
  
  <body>
	<select id="table">
	<option value='laishi_difang'>laishi_difang</option>
<option value='laishi_mingyun'>laishi_mingyun</option>
<option value='para'>para</option>
<option value='para_jiating'>para_jiating</option>
<option value='para_minggong'>para_minggong</option>
<option value='qianshi_fulu'>qianshi_fulu</option>
<option value='qianshi_shouming'>qianshi_shouming</option>
<option value='qianshi_shouyi'>qianshi_shouyi</option>
<option value='qianshi_tuohua'>qianshi_tuohua</option>
<option value='v_para'>v_para</option>
<option value='xianshi_caiyun_jiankang'>xianshi_caiyun_jiankang</option>
<option value='xianshi_jiating'>xianshi_jiating</option>
<option value='xianshi_minggong'>xianshi_minggong</option>
<option value='xianshi_shengchen_nian'>xianshi_shengchen_nian</option>
<option value='xianshi_shengchen_ri'>xianshi_shengchen_ri</option>
<option value='xianshi_shengchen_shi'>xianshi_shengchen_shi</option>
<option value='xianshi_shengchen_yue'>xianshi_shengchen_yue</option>
<option value='xianshi_shengxiao_ri'>xianshi_shengxiao_ri</option>
<option value='xianshi_shengxiao_shi'>xianshi_shengxiao_shi</option>
<option value='xianshi_shengxiao_yue'>xianshi_shengxiao_yue</option>
<option value='xianshi_shouming'>xianshi_shouming</option>
<option value='xianshi_simasha'>xianshi_simasha</option>
	</select>   
<button id="submit">ok</button>
   <table id="content" width="100%">
   </table>
  </body>
</html>
